#!/bin/sh
#
# Simple script for installing xmpp-py dependency
#
# Author: iyo

# Direct link for xmpppy file
FILE="http://dfn.dl.sourceforge.net/sourceforge/xmpppy/xmpppy-0.5.0rc1.tar.gz"

if echo "import xmpp" | python 2> /dev/null ; then
	echo "Dependency is already installed"
	exit 1
else
	# Installing
	TMPDIR=$(mktemp -d /tmp/nora-bot.XXXXXX || { echo "Error while creating temp directory" > /dev/stderr ; exit 1 ; } )
	CURDIR="$(pwd)"
	cd "$TMPDIR"
	echo "Downloading.."

	TMPFILE="xmpppy.tar.gz"
	wget "$FILE" -O "$TMPFILE"

	echo "Extracting.."
	tar xzf "$TMPFILE"

	echo "Moving files.."
	mv xmpppy-*/xmpp "$CURDIR"

	echo "Cleaning.."
	cd
	rm -r $TMPDIR
fi
